﻿using TestingConcurrencyBenchmark.Helpers;
using TestingConcurrencyBenchmark.Problems.DiningPhilosophers.Philosophers;

namespace TestingConcurrencyBenchmark.Problems.DiningPhilosophers.DiningPhilosophersSolutions
{
    public class DiningPhilosophersWithLeftHandedRightHanded : AbstractDiningPhilosophers
    {
        private bool _returnLefty = true;

        public DiningPhilosophersWithLeftHandedRightHanded(int nbPhilosophers) : base(nbPhilosophers)
        {
        }

        protected override AbstractPhilosopher CreatePhilosopher(BenchmarkSemaphore leftFork, BenchmarkSemaphore rightFork)
        {
            if (_returnLefty)
            {
                _returnLefty = false;
                return new LeftHandedPhilosopher(leftFork, rightFork);
            }
            return new RightHandedPhilosopher(leftFork, rightFork);
        }
    }
}